You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
479 B
12 lines
479 B
import { getArticle } from "#server/service/article";
|
|
import { getContextUser } from "#server/utils/context";
|
|
|
|
export default defineWrappedResponseHandler({ auth: "required" }, async (event) => {
|
|
const user = getContextUser(event)!;
|
|
const id = parseInt(event.context.params!.id);
|
|
if (isNaN(id)) return R.error("无效的 ID", null);
|
|
|
|
const article = await getArticle(id, user.id);
|
|
if (!article) return R.error("文章不存在", null);
|
|
return R.success(article);
|
|
});
|
|
|